/******************************************************************************************************
Copyright (C) 2008 Mestrelab Research S.L. All rights reserved.

This file is part of the MNova scripting toolkit.

Authorized users of MNova Software may use this file freely, but this file is provided AS IS
with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE.
*****************************************************************************************************/

/*globals
    print, MessageBox */
/*jslint plusplus: true, indent: 4 */


// Example dbPrePasteHook() and dbPostPasteHook() functions.
// To use, place this script in one of the Mnova scripts folders.

// This function, when in the global namespace, is called for each db item before pasting from MnDB to Mnova. 
// It must return true for the paste operation to proceed.

function dbPrePasteHook(aItemUrl, aDB, aItem) {
    "use strict";
    var msg = "Trying to paste {0} from database {1} ({2}).".format(aItem.type, aDB.name, aItemUrl);
    // msg += "\naDB=" + aDB.toString() + "\naItem=" + aItem.toString();
    print(msg);
    MessageBox.information(msg, MessageBox.Ok);
    // Paste only molecules
    if (aItem.type === "Molecule") {
        return true;
    }
    return false;
}

// This function, when in the global namespace, is called once after each successful pasting operation from MnDB to Mnova.
function dbPostPasteHook(aUuids) {
    "use strict";
    var i, msg = "dbPostPasteHook: Pasted {0} items.".format(aUuids.length);
    for (i = 0; i < aUuids.length; i++) {
        msg += "\nItem {0}: {1}".format(i, aUuids[i]);
    }
    MessageBox.information(msg, MessageBox.Ok);
}

// The end.
